package com.zqh.myfmmall.controller;



import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.api.ApiController;
import com.baomidou.mybatisplus.extension.api.R;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zqh.myfmmall.entity.UserAddr;
import com.zqh.myfmmall.result.Result;
import com.zqh.myfmmall.service.UserAddrService;
import com.zqh.myfmmall.utils.JwtUtil;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.io.Serializable;
import java.util.List;

/**
 * 用户地址 (UserAddr)表控制层
 *
 * @author KONO 曾淇杭哒！
 * @since 2022-01-20 20:53:00
 */
@RestController
@RequestMapping("userAddr")
@Api(tags = "地址管理")
public class UserAddrController extends ApiController {
    /**
     * 服务对象
     */
    @Resource
    private UserAddrService userAddrService;
    @Autowired
    private HttpServletRequest request;
    @GetMapping("list")
    public Result listUserAdd(){
        String token = request.getHeader("token");
        String userId = JwtUtil.getClaim(token).get("userId", String.class);
        List<UserAddr> userAddrs = userAddrService.getByUserId(userId);
        return Result.success(userAddrs);
    }
}

